# 进程间的通信, 用消息队列Queue

from multiprocessing import Queue
from multiprocessing.context import Process
import os
import time

# 该进程往消息队列写
def writeFunc(queue):
    i = 0
    while True:
        if not queue.full():
            queue.put(i)
            i += 1
        time.sleep(0.5)

# 该进程从消息队列读
def readFunc(queue):
    while True:  
        if not queue.empty():
            print(queue.get())
        time.sleep(0.1)



if __name__=='__main__':
    queue1 = Queue(3)
    pw = Process(target=writeFunc, args=(queue1,))    
    pr = Process(target=readFunc,  args=(queue1,))
    pw.start()
    pr.start()
    print('value')
    time.sleep(10)





